// import ElementUI from 'element-ui'
import './bus.js'
import './events.js'

import initPopupManager from './util/popper.js'
import inject from './router/inject.js'
import global from './global.js'
import fetch from './util/fetch.js'

import './assets/css/table.less'
import './assets/css/form.less'
import './assets/css/common.less'
import './assets/css/filter.less'

import ClKeepAlive from './components/ClKeepAlive.js'

import ClPage from './components/layout/ClPage.vue'
import ClHorAdaptive from './components/layout/ClHorAdaptive.vue'
import ClAdaptiveContent from './components/layout/ClAdaptiveContent.vue'
import ClTableFooter from './components/layout/ClTableFooter.vue'
import ClFormFooter from './components/layout/ClFormFooter.vue'
import ClFormBlock from './components/layout/ClFormBlock.vue'
import ClFormPart from './components/layout/ClFormPart.vue'
import ClTabPage from './components/layout/ClTabPage.vue'
import ClFilterItem from './components/layout/ClFilterItem.vue'
import ClFormExpandable from './components/layout/ClFormExpandable.vue'

import ClBreadcrumb from './components/nav/ClBreadcrumb.vue'
import ClSecondaryNav from './components/nav/ClSecondaryNav.vue'
import ClTertiaryNav from './components/nav/ClTertiaryNav.vue'

import ClButton from './components/ClButton.vue'
import ClDivider from './components/ClDivider.vue'
import ClPagination from './components/ClPagination.vue'
import ClFilter from './components/ClFilter.vue'
import ClSelectPopover from './components/ClSelectPopover.vue'
import ClPopover from './components/ClPopover.vue'
import ClTable from './components/ClTable.vue'

const install = Vue => {
    if (install.installed) {
        return
    }
    install.installed = true

    // Vue.use(ElementUI)
    Vue.prototype.$bus = new Vue()
    initPopupManager(Vue)

    Vue.component(ClKeepAlive.name, ClKeepAlive)

    Vue.component(ClPage.name, ClPage)
    Vue.component(ClHorAdaptive.name, ClHorAdaptive)
    Vue.component(ClAdaptiveContent.name, ClAdaptiveContent)
    Vue.component(ClTableFooter.name, ClTableFooter)
    Vue.component(ClFormFooter.name, ClFormFooter)
    Vue.component(ClFormBlock.name, ClFormBlock)
    Vue.component(ClFormPart.name, ClFormPart)
    Vue.component(ClTabPage.name, ClTabPage)
    Vue.component(ClFilterItem.name, ClFilterItem)
    Vue.component(ClFormExpandable.name, ClFormExpandable)

    Vue.component(ClButton.name, ClButton)
    Vue.component(ClBreadcrumb.name, ClBreadcrumb)
    Vue.component(ClSecondaryNav.name, ClSecondaryNav)
    Vue.component(ClTertiaryNav.name, ClTertiaryNav)
    Vue.component(ClDivider.name, ClDivider)
    Vue.component(ClPagination.name, ClPagination)
    Vue.component(ClFilter.name, ClFilter)
    Vue.component(ClSelectPopover.name, ClSelectPopover)
    Vue.component(ClPopover.name, ClPopover)
    Vue.component(ClTable.name, ClTable)
}

const CoreLib = {
    install, inject
}

export default CoreLib
export { global, fetch }
